package com.bookcode.dao;


import com.bookcode.entity.Course;
import com.bookcode.entity.Student;
import com.bookcode.entity.Teacher;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import javax.persistence.Column;
import java.util.List;


public interface TeacherRepository  extends JpaRepository<Teacher,Long> {

//    根据姓名查询教师
    @Query("from Teacher t where t.name=:name")
    Teacher findTeacherByName(@Param("name") String name);

    // 根据工号查找老师
    @Query("select b from Teacher b where b.gonghao=:gonghao")
    Teacher getTeacherByGonghao(@Param("gonghao") String gonghao);

    //根据老师手机号查找老师
    @Query("select b from Teacher b where b.phone=:phone")
    Teacher getTeacherByPhone(@Param("phone") String phone);

    //删除 某个工号下的老师
    @Modifying
    @Query("delete from Teacher b where b.gonghao=:gonghao")
    void deleteTeacherByGonghao(@Param("gonghao") String gonghao);
    //更新老师
//    @Modifying
//    @Query("update Teacher u set u. = ?1 where u.lastname = ?2")
//    int setFixedFirstnameFor(String firstname, String lastname);
//
//    @Query("from Course c where c.teacherId=:teacherId")
//    List<Course> findCoursesByTeacher(@Param("teacherId") Long teacherId);

}


